package org.common.utils.fasttest;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;

/**
 * @author zhouzhibing
 * @date 2024/11/15
 */
public class TestIntrospector {


    public static void test() throws Exception {
        Person person = new Person();
        person.setId(123456789);
        person.setName("张三");

        testGetProperty(person);
    }


    public static void testGetProperty(Person person) throws Exception {
        PropertyDescriptor pd = new PropertyDescriptor("id", Person.class);
        Method method = pd.getReadMethod();
        Object id = method.invoke(person);
        System.out.println(id);
    }


    public static void testGetProperty1(Person person) throws Exception {
        PropertyDescriptor pd = new PropertyDescriptor("id", Person.class);
        Method method = pd.getReadMethod();
        Object id = method.invoke(person);
        System.out.println(id);
    }


    private static class Person {
        private int id;
        private String name;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
